{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d45a9abd-307c-48ad-8578-be60751b5a7f",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/linked-list-cycle-ii\n",
    "\n",
    "\n",
    "Runtime: 120 ms, faster than 9.85% of C++ online submissions for Linked List Cycle II.\n",
    "Memory Usage: 8.2 MB, less than 16.94% of C++ online submissions for Linked List Cycle II.\n",
    "\n",
    "\n",
    "```cpp\n",
    "class Solution {\n",
    "public:\n",
    "    ListNode *detectCycle(ListNode *head) {\n",
    "      //6:41\n",
    "      vector<ListNode*> l;\n",
    "      auto ok = false;\n",
    "      auto index = 0;\n",
    "      auto node = head;\n",
    "      while (node != nullptr) {\n",
    "        if (find(l.begin(), l.end(), node) != l.end()) {\n",
    "          ok = true;\n",
    "        }\n",
    "        l.push_back(node);\n",
    "        if (ok) {\n",
    "          return l[index];\n",
    "        }\n",
    "        node = node->next;\n",
    "        index++;\n",
    "      }\n",
    "      return nullptr;\n",
    "      //6:44\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "50d32053-2a55-4a83-bc23-5e7c59ba9765",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "name": ""
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
